package com.hzit.sk.enums;

public enum OrderStatusEnum {

    //1.写出所有类型
    UNPAY(0,"未支付"),
    PAY_FINSHEND(1,"已支付"),
    SEND(2,"已发货");

    //2.枚举的构造方法
    OrderStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    //3. get,set方法
    private int code;

    private String desc;


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }


    //4.根据code 获取desc， 根据desc获取code

    public String  getDesc(int code){

        for ( OrderStatusEnum o :OrderStatusEnum.values()){
            if(o.getCode() == code){
                return o.getDesc();
            }
        }
        return "";

    }


    public Integer getCode(String desc){

        for ( OrderStatusEnum o :OrderStatusEnum.values()){
            if(o.getDesc().equals(desc)){
                return o.getCode();
            }
        }
        return null;

    }



}
